home *** CD-ROM | disk | FTP | other *** search
/ Aminet 8 / Aminet 8 (1995)(GTI - Schatztruhe)[!][Oct 1995].iso / Aminet / disk / cdrom / CDR210kit.lha / nectools / playnext.c < prev    next >
C/C++ Source or Header  |  1995-05-11  |  2KB  |  80 lines

  1. /*
  2.     NEC-CDR-210 Play Audio
  3.  
  4.     by dbalster@uni-paderborn.de
  5. */
  6.  
  7. #include <exec/exec.h>
  8. #include <dos/dos.h>
  9. #include <devices/scsidisk.h>
  10. #include <proto/exec.h>
  11. #include <proto/dos.h>
  12.  
  13. #include <string.h>
  14.  
  15. UBYTE    version[] = "$VER: playaudio 0.9 for the NEC CDR-210 drive";
  16.  
  17. ULONG    sense [5];
  18. UBYTE    buffer [10];
  19. UBYTE    cmd_play[]    = { 0xD9,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0 };
  20. UBYTE    cmd_index[]    = { 0xD8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80 };
  21.  
  22.  
  23. #define TEMPLATE "DEVICE/A,UNIT/N/A,TRACK/N"
  24.  
  25. #define bcd(x) (((x/10)<<4)|(x%10))
  26.  
  27. struct {
  28.     STRPTR    device;
  29.     ULONG    unit, track, pad;
  30. } args;
  31.  
  32. ULONG main (VOID)
  33. {
  34.     struct MsgPort *mp;
  35.     struct SCSICmd scsi;
  36.     struct RDArgs *rdargs;
  37.     struct IOStdReq *ior;
  38.     UBYTE trk = 1;
  39.     
  40.     if (rdargs = ReadArgs(TEMPLATE,(LONG*)&args,NULL))
  41.     {
  42.         if (args.track) trk = *(ULONG*)args.track;
  43.     
  44.         if ((trk<1)||trk>99) trk=1;    // only 1..99 allowed
  45.     
  46.         if(mp=CreateMsgPort())
  47.         {
  48.             if(ior=(struct IOStdReq*)CreateIORequest(mp,sizeof(struct IOStdReq)))
  49.             {
  50.                 if(!OpenDevice(args.device,*(ULONG*)args.unit,ior,0))
  51.                 {
  52.                     ior->io_Command    = HD_SCSICMD;
  53.                     ior->io_Data    = (APTR) &scsi;
  54.                     ior->io_Length    = sizeof(struct SCSICmd);
  55.  
  56.                     scsi.scsi_Data        = (UWORD*) buffer;
  57.                     scsi.scsi_Length    = 0;
  58.                     scsi.scsi_CmdLength    = 10;
  59.                     scsi.scsi_Flags        = SCSIF_AUTOSENSE|SCSIF_WRITE;
  60.                     scsi.scsi_SenseData    = (UBYTE*) sense;
  61.                     scsi.scsi_SenseLength    = 20;
  62.                     scsi.scsi_Command    = cmd_index;
  63.                     cmd_index [2]        = bcd(trk);
  64.                     DoIO(ior);
  65.                     scsi.scsi_Command    = cmd_play;
  66.                     DoIO(ior);
  67.  
  68.                     CloseDevice((struct IORequest*)ior);
  69.                 }
  70.                 DeleteIORequest((struct IORequest*)ior);
  71.             }
  72.             DeleteMsgPort(mp);
  73.         }
  74.         FreeArgs(rdargs);
  75.     }
  76.     else PrintFault(IoErr(),0);
  77.  
  78.     return RETURN_OK;
  79. }
  80.